public with sharing class Utilities {

	///////
	private static string chr(double num){
		string[] alfabeto=new String[] {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9'};
		Integer index = Integer.ValueOf(num);
		return alfabeto[index]; 
	}
	
	//////
	public static String password(){
		string pwd;
	
	for(Double i=0;i<12;i++){
		pwd=pwd+chr(Math.random()*58);
	
	}
	
	return pwd;
	}
	
	////////////Method that validates the extension of a file.  Author: Víctor Galván
	////////////Arguments: fileName-String with the name of the file
	////////////		   permittedExtensions: Array or List prefilled with the permitted extensions
	public static boolean isValidExtension(String fileName, String[] permittedExtensions){
		System.debug('Nombre del archivo recibido: '+fileName);
		boolean valid=false;
		if(fileName != '' || fileName != null || permittedExtensions != null){
			String extension = fileName.substringAfterLast('.');
			for(Integer i = 0; i<=permittedExtensions.size()-1;i++){
				if(extension==permittedExtensions[i])valid=true;
			}
		}else{
			valid = false;
		}
		return valid;
	} 

}